package httpUtils;

import okhttp3.*;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

public class HttpClient {


    public static Response get() {

        return null;
    }


    public static Response post(String url, RequestBody body) {

        OkHttpClient client = new OkHttpClient().newBuilder()
                .connectTimeout(20000, TimeUnit.SECONDS)
                .readTimeout(20000, TimeUnit.SECONDS)
                .sslSocketFactory(SSLSocketClient.getSSLSocketFactory(), SSLSocketClient.getX509TrustManager())
                .hostnameVerifier(SSLSocketClient.getHostnameVerifier())
                .build();

        Request request = new Request.Builder()
                .url(Config.HOST + url)
                .post(body)
                .build();

        try {
            Call call = client.newCall(request);
            Response response = call.execute();
            return response;
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }

}
